<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        // 1. 宏任务和微任务
        function fn1() {
            return new Promise((resolve, reject) => {
                console.log('fn1');
                reject('ok')
            })
        }

        ; (async () => {
            console.log(1);
            try {
                await fn1();
            } catch (e) {
                console.log(e);
            }
            console.log(2);
        })()

        new Promise((resolve, reject) => {
            console.log(3);
            resolve(4)
        })
            .then(data => {
                console.log(data);
            })

        setTimeout(() => {
            console.log(5);
        })

        console.log(6);


        Promise.resolve(100).then(data => {
            console.log(data);
        })
    </script>
</body>

</html>